home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / C / Screens / DoubleBuffer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-04  |  1.0 KB  |  47 lines

  1. /*
  2. ** Double Buffer Demo
  3. ** ------------------
  4. ** This simple demo shows how to double buffer the screen.
  5. **
  6. ** To compile with SAS/C:
  7. **
  8. **    1> sc DoubleBuffer.c link startup=LIB:GMSMain.o data=far
  9. **
  10. */
  11.  
  12. #include <proto/games.h>
  13.  
  14. extern struct GMSBase *GMSBase;
  15. ULONG  _XCEXIT = NULL;
  16. ULONG  PREFSNAME = DEFAULT;
  17.  
  18. void main(void)
  19. {
  20.   struct Picture *picture;
  21.   struct GameScreen *screen;
  22.  
  23.   if (picture = LoadPicFile("GMS:demos/data/PIC.Green",GETPALETTE|VIDEOMEM)) {
  24.  
  25.      if (screen = AddScreenTags(TAGS_GAMESCREEN,NULL,
  26.         GSA_MemPtr1,  picture->Data,
  27.         GSA_Planes,   picture->Planes,
  28.         GSA_ScrMode,  picture->ScrMode,
  29.         GSA_ScrType,  picture->ScrType,
  30.         GSA_ScrWidth, picture->Width,
  31.         GSA_ScrHeight,picture->Height,
  32.         GSA_Palette,  picture->Palette,
  33.         GSA_Attrib,   DBLBUFFER|CENTRE,
  34.         TAGEND)) {
  35.  
  36.         ShowScreen(screen);
  37.         while (!(ReadMouse(JPORT1)&MB_LMB)) {
  38.           WaitVBL();
  39.           SwapBuffers(screen);
  40.         }
  41.      FreePic(picture);
  42.      }
  43.   DeleteScreen(screen);
  44.   }
  45. }
  46.  
  47.